<template>
	<view class="body">
		<view class="header">
			<infomationVue :query="query"></infomationVue>
		</view>
		<scroll-view scroll-y="true" class="scroll-view" @scrolltolower="scrolltolower">
			<view class="comlum_box" v-if="list.length">
				<view v-for="(item,index) in list" :key="index" class="Item">
					<view class="size">
						{{item.content}}
					</view>
					<view class="time">
						{{item.add_date}}
					</view>
				</view>
			</view>
			<empty v-else :content="'跟进记录'"></empty>
		</scroll-view>
		<view class="foot">
			<view class="btn" @click="popupShow = true">
				添加跟进记录
			</view>
		</view>
		<u-toast ref="uToast" />
		<remarkVue :popupShow="popupShow" :content="content" @cancel="cancel" @sure="sure" :title="'添加跟进记录'"
			:placeholder="'请填写跟进记录（30字左右描述）'" :sureStr="'确认添加'"></remarkVue>
	</view>
</template>

<script>
	import infomationVue from '../../coach/components/infomation.vue'
	import remarkVue from '../../coach/components/remark.vue'
	import empty from '@/components/empty.vue'
	import {
		storeMemberfollowList,
		storeMemberfollowAdd
	} from '@/api/coach.js'
	export default {
		components: {
			remarkVue,
			infomationVue,
			empty
		},
		data() {
			return {
				content: '',
				popupShow: false,
				infomation: {
					user_id: '',
					page: 1
				},
				query: {
					img: 'https://img0.baidu.com/it/u=3974459751,424647287&fm=253&fmt=auto&app=138&f=JPEG?w=398&h=389',
					name: '夕羊羊',
					sex: 1,
					age: '男丨24岁 178cm 68kg',
					phone: '13216193357',
					shop: '温州中庚漫游天地店',
					time: '2024-09-24',
					remark: '天天来，夕总',
				},
				list: []
			}
		},
		onLoad(e) {
			this.infomation.user_id = e.user_id
			this.getstoreMemberfollowList()
		},
		methods: {
			scrolltolower() {
				this.infomation.page++
				this.getstoreMemberfollowList()
			},
			getstoreMemberfollowAdd(str) {
				storeMemberfollowAdd({
					user_id: this.infomation.user_id,
					content: str
				}).then(({
					data: res
				}) => {
					if (res.code == 1) {
						this.$refs.uToast.show({
							title: res.msg,
							type: 'success',
							icon: false
						})
						this.infomation.page = 1
						this.getstoreMemberfollowList()
					}
				})
			},
			getstoreMemberfollowList() {
				storeMemberfollowList(this.infomation).then(({
					data: res
				}) => {
					console.log('res', res)
					if (res.code == 1) {
						this.query = res.data.user_info
						const list = []
						this.status = 'loading'
						if (this.query.page > res.data.all_page) {
							console.log('nomore');
							this.status = 'nomore'
							return false
						} else {
							console.log('more');
							this.status = 'more'
							this.list = this.list.concat(res.data.list)
						}
					}
				})
			},
			cancel() {
				this.popupShow = false
			},
			sure(str) {
				if (str) {
					this.query.page = 1
					this.list = []
					this.getstoreMemberfollowAdd(str)
					this.popupShow = false
				} else {
					uni.showToast({
						title: '请填写跟进记录',
						icon:'none'
					})
				}

			}
		}
	}
</script>

<style lang="scss">
	page {
		background: #e9e9e9;
	}

	.body {
		display: flex;
		flex-direction: column;
		align-items: center;
	}

	.header {}

	.scroll-view {
		height: 77vh;

		.comlum_box {
			display: flex;
			flex-direction: column;
			align-items: center;
			padding-top: 24rpx;

			.Item {
				width: 702rpx;
				background: #ffffff;
				border-radius: 16rpx;
				padding: 24rpx;
				margin-bottom: 20rpx;

				.size {
					width: 100%;
					font-size: 28rpx;
					font-family: PingFang SC, PingFang SC-Medium;
					font-weight: 500;
					text-align: left;
					color: #000000;
					margin-bottom: 8rpx;
				}

				.time {
					font-size: 24rpx;
					font-family: PingFang SC, PingFang SC-Regular;
					font-weight: 400;
					text-align: left;
					color: #666666;
				}
			}
		}
	}

	.foot {
		position: fixed;
		bottom: 0;
		width: 750rpx;
		height: 160rpx;
		background: #ffffff;
		box-shadow: 0rpx 8rpx 28rpx 0rpx rgba(166, 179, 194, 0.30);
		display: flex;
		justify-content: center;
		padding-top: 10rpx;

		.btn {
			width: 710rpx;
			height: 88rpx;
			background: #73F0EA;
			border-radius: 16rpx;
			font-size: 34rpx;
			font-family: PingFang SC, PingFang SC-Bold;
			font-weight: 700;
			text-align: center;
			color: #ffffff;
			display: flex;
			align-items: center;
			justify-content: center;
		}
	}
</style>